package com.tgy.esp32Service.service.Impl;

import com.tgy.esp32Service.constant.CommonConsts;
import com.tgy.esp32Service.service.EspService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/***
 * @ClassName: EspServiceImpl
 * @Description: 实现类
 * @Auther: tanggy3
 * @Date: 15:49 2022/9/14
 * @version : V1.0
 */
@Slf4j
@Service
@AllArgsConstructor
public class EspServiceImpl implements EspService {

    private final RedisTemplate redisTemplate;

    @Override
    public String sendMsg(String msg) {
        redisTemplate.opsForValue().set(CommonConsts.ESP_KEY, msg);
        return "send success";
    }

    @Override
    public String getMsg() {
        return redisTemplate.opsForValue().get(CommonConsts.ESP_KEY).toString();
    }
}
